import React, {useState, useEffect, useContext} from "react";
import './index.scss';
import {Avatar} from 'antd';
import Icon from '@/plugins/Icon';
import avatarImg from "@/assets/avatar.jpg";
import {
    getLoginUserInfo
} from "../../../service/getLoginUserInfo.service";
function Index() {
    const [userData, setData] = useState<any>({});
    useEffect(()=>{
        (async function init() {
            const data = (await getLoginUserInfo()).data;
            setData(Object.assign({...userData}, data));
        })();
    },[]);
    return (
        <div id='page'>
            <>
                {/*User context value {user}*/}
                <div className="user-box">
                    <div className="avatar">
                        <Avatar size={74} src={avatarImg} className="avatar"/>
                        <p className="userName">{userData.userName}</p>
                        <p className="email">{userData.userEmail}</p>
                    </div>
                    <div className="detail">
                        <p className="list code">
                        <span className="title">
                            <Icon name={'icon-name'} className='c-icon'/>业务系统名称：
                        </span>
                            <span>{userData?.appId?.appName}</span>
                        </p>
                        <p className="list code">
                            <span className="title"><Icon name={'icon-bianma'} className='c-icon'/>业务系统编码：</span>
                            <span>{userData?.appId?.clientId}</span>
                        </p>
                        <p className="list code">
                            <span className="title"><Icon name={'icon-a-hetong'} className='c-icon'/>业务系统凭证：</span>
                            <span>{userData?.appId?.appSecret}</span>
                        </p>
                        <p className="list code">
                            <span className="title"><Icon name={'icon-zhuangtai1'} className='c-icon'/>业务系统状态：</span>
                            <span>{userData?.appId?.appStatus}</span>
                        </p>
                        <p className="list code">
                            <span className="title"><Icon name={'icon-suijiyonghu'} className='c-icon'/>用户状态：</span>
                            <span>{userData?.userState === 'NORMAL' ? '正常' : '-'}</span>
                        </p>
                        <p className="list code">
                            <span className="title"><Icon name={'icon-creditlevel'} className='c-icon'/>用户级别：</span>
                            <span>{userData?.userLevel === 'NORMAL' ? '正常' : '-'}</span>
                        </p>
                        <p className="list code">
                        <span className="title">
                            <Icon name={'icon-zhanghaoquanxianguanli'} className='c-icon'/>用户账号：
                        </span>
                            <span>{userData?.userName}</span>
                        </p>
                        <p className="list code">
                        <span className="title">
                            <Icon name={'icon-zuzhiqunzu'} className='c-icon'/>所在组织：
                        </span>
                            <span>{userData?.userOrg?.orgFullName}</span>
                        </p>

                        <p className="list code">
                        <span className="title">
                            <Icon name='PhoneOutlined' className='c-icon'/>手机号：
                        </span>
                            <span>{userData.userMobile}</span>
                        </p>
                        <p className="list code">
                        <span className="title">
                           <Icon name={'icon-weixin'} className='c-icon'/>微信号：
                        </span>
                            <span>{userData.userWx}</span>
                        </p>
                        <p className="list code">
                        <span className="title">
                            <Icon name='AimOutlined' className='c-icon'/>用户地址：
                        </span>
                            <span>{userData.userAddr}</span>
                        </p>

                    </div>
                </div>
            </>
        </div>
    );
}

export default Index;
